// 配置折叠框按钮的响应事件
function configCollapse(){
  const buttons = [...document.querySelectorAll(".collapse_button")]
  for (let i = 0; i < buttons.length; i++) {
   const bt = buttons[i]
   bt.onclick = function({target}){
       const contentDiv = target.nextElementSibling
       if (contentDiv.style.display){
           contentDiv.style.display = ""
           bt.innerText = "+"
       }else{
           contentDiv.style.display = "block"
           bt.innerText = "-"
       }
   }
}
}

// 被屏蔽楼层点击解除屏蔽
function configBlocked(){
    const buttons = [...document.querySelectorAll(".blocked_warning")]
      for (let i = 0; i < buttons.length; i++) {
       const bt = buttons[i]
       bt.onclick = function({target}){
           const contentDiv = target.nextElementSibling
           contentDiv.style.display = "block"
           target.style.display = "none"
       }
    }
}


function configHeader(){
 const headers = [...document.querySelectorAll(".comment_header"),...document.querySelectorAll(".hot_reply_header")]
  for (let i = 0; i < headers.length; i++) {
   const header = headers[i]
   header.onclick = function({target}){
       const contentDiv = target.nextElementSibling
       if (contentDiv.style.display != "none"){
           contentDiv.style.display = "none"
       }else{
           contentDiv.style.display = "block"
       }
   }
}
}


// 图片加载完成回调,清空class
function imageOnLoad({target}){
//    console.log(target.tagName)
    target.className=''
}
// 滚动到指定回复id
function scrollToReply(id){
    console.log("滚动到回复ID = "+id)
    document.getElementsByClassName('reply_container_'+id)[0].scrollIntoView({behavior: "smooth", block: "start", inline: "center"})
}
function scrollToFloor(num){
    console.log("滚动到楼层 = "+num)
    document.getElementsByClassName('floor_container_'+num)[0].scrollIntoView({behavior: "smooth", block: "start", inline: "center"})
}

// 修改指定回复的赞数
function setAgreeCount(id,dc){
    console.log("修改赞数: 回复id = "+id+" 变动值:"+dc)
    const spans = document.getElementsByClassName('agree_count_'+id)
    console.log(spans.length)
    for (const item of spans){
        item.innerText=parseInt(item.innerText)+dc
    }
}



(function f(argument) {
    configCollapse();
    configHeader();
    configBlocked();
})();